; Music of BD Story 1 (1991) (JLM & MLD)
; Ripped by Megachur the 27/03/2009

;10 ''''''''''''''''''''''''''''''''''
;20 ' BD STORY 1 par JLM & MLD 8.91  '
;30 ' digits PATRICK AUBERT          ' 
;40 ' routines windows P. AUBERT &   '
;50 '      NULLOS CRACKER            '  
;60 ' Graphismes & scenario  MLD     '
;70 '                                '
;80 ''''''''''''''''''''''''''''''''''

; Need System Vectors

	write "BDSTORY1.BIN"

music_date_rip	equ &1b39
music_adr	equ &7000
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"

	jp l7151	; init music
	jp l7204	; play music
	jp l70cc
	jp l702a
	jp l702f
	jp l7034
	jp l7039
	jp l703e
	jp l7043
	jp l7048
	jp l704d
	jp l7052
	jp l7057
	jp l705c
.l702a
	ld hl,l7069
	jr l7061
.l702f
	ld hl,l7072
	jr l7061
.l7034
	ld hl,l707b
	jr l7061
.l7039
	ld hl,l7084
	jr l7061
.l703e
	ld hl,l708d
	jr l7061
.l7043
	ld hl,l7096
	jr l7061
.l7048
	ld hl,l709f
	jr l7061
.l704d
	ld hl,l70a8
	jr l7061
.l7052
	ld hl,l70b1
	jr l7061
.l7057
	ld hl,l70ba
	jr l7061
.l705c
	ld hl,l70c3
	jr l7061
.l7061
	push ix
	call #bcaa
	pop ix
	ret
.l7069
	db #82,#00,#00,#e7,#03,#00,#0f,#02
.l7072 equ $ + 1
	db #00,#82,#01,#01,#c8,#00,#00,#00
.l707b equ $ + 2
	db #00,#00,#82,#01,#02,#14,#00,#00
.l7084 equ $ + 3
	db #00,#00,#00,#82,#00,#03,#14,#00
.l708d equ $ + 4
	db #00,#0f,#64,#00,#82,#00,#00,#90
.l7096 equ $ + 5
	db #01,#00,#0f,#02,#00,#81,#01,#00
.l709f equ $ + 6
	db #00,#00,#14,#00,#00,#00,#81,#02
.l70a8 equ $ + 7
	db #00,#00,#00,#1f,#00,#00,#00,#84
	db #00,#04,#2c,#01,#00,#0f,#0f,#00
.l70b1
	db #84,#00,#05,#64,#00,#00,#0f,#0a
.l70ba equ $ + 1
	db #00,#84,#03,#00,#64,#00,#00,#00
.l70c3 equ $ + 2
	db #19,#00,#84,#00,#06,#64,#00,#00
	db #0f
	jr z,l70cc
.l70cc
	ld a,#01
	ld hl,l7115
	call #bcbc
	ld a,#02
	ld hl,l7119
	call #bcbc
	ld a,#03
	ld hl,l711d
	call #bcbc
	ld a,#01
	ld hl,l712d
	call #bcbf
	ld a,#02
	ld hl,l7134
	call #bcbf
	ld a,#03
	ld hl,l713b
	call #bcbf
	ld a,#04
	ld hl,l7142
	call #bcbf
	ld a,#05
	ld hl,l7146
	call #bcbf
	ld a,#06
	ld hl,l714a
	call #bcbf
	ret
.l7119 equ $ + 4
.l7115
	db #01,#10,#ff,#03,#01,#10,#ff,#05
.l711d
	db #05,#01,#0f,#01,#0a,#00,#01,#01
	db #f1,#01,#05,#00,#01,#01,#0f,#01
.l7134 equ $ + 7
.l712d
	db #82,#01,#64,#01,#01,#9b,#01,#82
.l713b equ $ + 6
	db #01,#64,#01,#01,#a1,#01,#82,#03
.l7142 equ $ + 5
	db #32,#03,#01,#9c,#03,#81,#01,#fb
.l714a equ $ + 5
.l7146 equ $ + 1
	db #01,#81,#01,#f6,#01,#82
	db #01,#ce,#03,#01,#32,#03
;
.real_init_music
;
.l7151
	call l7160
	ld hl,l73bb
	ld de,l73c8
	ld bc,l73d5
	jp l71d0
.l7160
	ld a,#01
	ld hl,l71a1
	call #bcbc
	ld a,#02
	ld hl,l71a8
	call #bcbc
	ld a,#03
	ld hl,l71af
	call #bcbc
	ld a,#04
	ld hl,l71b6
	call #bcbc
	ld a,#05
	ld hl,l71ba
	call #bcbc
	ld a,#06
	ld hl,l71be
	call #bcbc
	ld a,#07
	ld hl,l71c2
	call #bcbc
	ld a,#01
	ld hl,l71c9
	call #bcbf
	ret
.l71a8 equ $ + 7
.l71a1
	db #02,#01,#0d,#01,#0d,#ff,#01,#02
.l71af equ $ + 6
	db #01,#0d,#01,#0d,#ff,#02,#02,#01
.l71b6 equ $ + 5
	db #0d,#01,#0d,#ff,#03,#01,#10,#ff
.l71be equ $ + 5
.l71ba equ $ + 1
	db #03,#01,#10,#ff,#07,#01,#10,#ff
.l71c2 equ $ + 1
	db #04,#02,#07,#02,#01,#64,#00,#64
.l71c9
	db #82,#02,#01,#04,#02,#ff
	inc b
.l71d0
	ld (l744c),hl
	ld (l744e),de
	ld (l7450),bc
	ld ix,(l744c)
	call l71f3
	ld ix,(l744e)
	call l71f3
	ld ix,(l7450)
	call l71f3
	jp #bca7
.l71f3
	ld l,(ix+#00)
	ld h,(ix+#01)
	ld (ix+#02),l
	ld (ix+#03),h
	ld (ix+#0a),#00
	ret
;
.play_music
;
.l7204
	ld hl,(l744c)
	call l7213
	ld hl,(l744e)
	call l7213
	ld hl,(l7450)
.l7213
	ld de,l73e2
	ld bc,#000d
	push hl
	ldir
	call l7229
	pop de
	ld hl,l73e2
	ld bc,#000d
	ldir
	ret
.l7229
	ld a,(l73ed)
	bit 0,a
	ret nz
	bit 2,a
	jp nz,l7301
	ld ix,(l73e4)
	ld a,(ix+#00)
	cp #ff
	jp z,l72c5
	ld b,a
	and #c0
	jr z,l7279
	cp #40
	jr z,l72aa
	cp #80
	jp z,l72f0
.l724e
	inc ix
	ld a,b
	and #3f
	add a
	ld c,a
	ld b,#00
	ld hl,(l73e6)
	add hl,bc
	ld c,(hl)
	inc hl
	ld b,(hl)
	ld (l73e4),bc
	ld a,(l73ec)
	ld c,a
	inc a
	inc a
	ld (l73ec),a
	ld b,#00
	ld hl,(l73e8)
	add hl,bc
	push ix
	pop bc
	ld (hl),c
	inc hl
	ld (hl),b
	jr l7229
.l7279
	ld a,(l73ee)
	add b
	and #3f
	add a
	ld c,a
	ld b,#00
	ld e,(ix+#01)
	ld hl,l7341
	add hl,bc
	ld c,(hl)
	inc hl
	ld b,(hl)
	ld ix,(l73ea)
	ld (ix+#03),c
	ld (ix+#04),b
	ld (ix+#07),e
	ld hl,(l73ea)
	call #bcaa
	ret nc
	ld hl,(l73e4)
	inc hl
	inc hl
	ld (l73e4),hl
	ret
.l72aa
	ld a,b
	and #0f
	ld b,(ix+#01)
	inc ix
	inc ix
	ld (l73e4),ix
	ld ix,(l73ea)
	ld (ix+#01),a
	ld (ix+#02),b
	jp l7229
.l72c5
	ld a,(l73ec)
	or a
	jr z,l72e1
	dec a
	dec a
	ld (l73ec),a
	ld c,a
	ld b,#00
	ld hl,(l73e8)
	add hl,bc
	ld c,(hl)
	inc hl
	ld b,(hl)
	ld (l73e4),bc
	jp l7229
.l72e1
	ld a,(l73ed)
	bit 1,a
	ret nz
	ld hl,(l73e2)
	ld (l73e4),hl
	jp l7229
.l72f0
	ld a,(ix+#01)
	ld (l73ee),a
	inc ix
	inc ix
	ld (l73e4),ix
	jp l7229
.l7301
	ld ix,(l73e4)
	ld a,(ix+#00)
	cp #ff
	jp z,l72c5
	ld b,a
	and #c0
	jp nz,l724e
	ld a,b
	add a
	add a
	add a
	add b
	ld c,a
	ld b,#00
	ld a,(ix+#01)
	ld ix,(l73ea)
	ld e,(ix+#00)
	ld ix,l740a
	add ix,bc
	ld (ix+#07),a
	ld (ix+#00),e
	push ix
	pop hl
	call #bcaa
	ret nc
	ld hl,(l73e4)
	inc hl
	inc hl
	ld (l73e4),hl
	ret
.l7341
	dw #0777,#070c,#06a7,#0647
	dw #05ed,#0598,#0547,#04fc
	dw #04b4,#0470,#0431,#03f4
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01d3,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #0000
.l73bb
	dw l7452
	dw l7500,l74e2,l742e,l73ef
	db #02,#04,#00
.l73c8
	dw l7484,l7560,l74e8,l7438
	dw l73f8
	db #02,#00,#00
.l73d5
	dw l74bf,l7601,l74ee,l7442
	dw l7401
	db #02,#00,#00
.l73e8 equ $ + 6
.l73e6 equ $ + 4
.l73e4 equ $ + 2
.l73e2
	dw l74bf,l7601,l74ee,l7442
.l73ea
	dw l7401
.l73ef equ $ + 3
.l73ee equ $ + 2
.l73ed equ $ + 1
.l73ec
	db #02,#00,#00,#01,#00,#00,#00,#00
.l73f8 equ $ + 4
	db #00,#00,#00,#00,#02,#06,#00,#c9
.l7401 equ $ + 5
	db #00,#00,#00,#18,#00,#04,#04,#00
.l740a equ $ + 6
	db #98,#05,#00,#00,#18,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#01
	db #01,#00,#00,#00,#1f,#00,#18,#00
	db #01,#02,#00,#00,#00,#0f,#00,#18
	db #00,#01,#03,#00,#0a,#00,#01,#00
.l742e equ $ + 2
	db #18,#00,#5f,#74,#00,#00,#00,#00
.l7438 equ $ + 4
	db #00,#00,#00,#00,#9e,#74,#00,#00
.l7442 equ $ + 6
	db #00,#00,#00,#00,#00,#00,#cf,#74
	db #00,#00,#00,#00,#00,#00,#00,#00
.l7450 equ $ + 4
.l744e equ $ + 2
.l744c
	dw l73bb,l73c8,l73d5
.l7452
	db #c0,#c0,#c0,#c0,#c0,#c0,#c0,#c1
	db #c0,#c0,#c0,#c0,#c0,#c0,#c0,#c1
	db #c0,#c0,#c1,#c1,#c0,#c0,#c1,#c1
	db #c0,#c0,#c0,#c0,#c0,#c0,#c0,#c1
	db #c0,#c0,#c0,#c0,#c0,#c0,#c0,#c1
	db #c0,#c0,#c1,#c1,#c0,#c0,#c1,#c1
.l7484 equ $ + 2
	db #c2,#ff,#80,#00,#c0,#2b,#0c,#26
	db #0c,#23,#0c,#1f,#0c,#2c,#0c,#27
	db #0c,#23,#0c,#20,#0c,#c0,#1f,#30
	db #1e,#30,#c1,#c1,#c2,#c2,#c0,#2b
	db #0c,#26,#0c,#23,#0c,#1f,#0c,#2c
	db #0c,#27,#0c,#23,#0c,#20,#0c,#c0
	db #1f,#30,#1e,#30,#c1,#c1,#c2,#c2
.l74bf equ $ + 5
	db #45,#01,#28,#c0,#ff,#44,#00,#80
	db #00,#c0,#08,#18,#14,#18,#c0,#06
	db #18,#12,#18,#c1,#c1,#c2,#c2,#c0
	db #08,#18,#14,#18,#c0,#06,#18,#12
	db #18,#c1,#c1,#c2,#c2,#09,#c0,#ff
.l74e8 equ $ + 6
.l74e2
	db #f4,#74,#05,#75,#18,#75,#1b,#75
.l74ee equ $ + 4
	db #50,#75,#99,#75,#b8,#75,#f5,#75
	db #36,#76,#01,#18,#03,#18,#02,#18
.l7500 equ $ + 6
	db #03,#18,#01,#18,#03,#18,#02,#18
	db #03,#18,#ff,#01,#18,#03,#18,#02
	db #18,#03,#18,#02,#18,#02,#18,#02
	db #18,#02,#0c,#02,#0c,#ff,#03,#c0
	db #ff,#45,#01,#21,#24,#21,#0c,#21
	db #18,#28,#30,#21,#18,#24,#30,#1f
	db #24,#1f,#0c,#1f,#18,#28,#30,#21
	db #18,#24,#0c,#26,#0c,#24,#0c,#23
	db #0c,#21,#24,#21,#0c,#21,#18,#28
	db #30,#21,#18,#24,#30,#1a,#24,#1a
	db #0c,#1a,#18,#1a,#18,#ff,#46,#00
	db #24,#0c,#24,#0c,#24,#0c,#24,#0c
.l7560 equ $ + 6
	db #24,#30,#24,#30,#24,#30,#27,#18
	db #27,#18,#27,#0c,#27,#24,#22,#18
	db #22,#18,#22,#18,#22,#0c,#22,#0c
	db #24,#0c,#24,#0c,#24,#0c,#24,#0c
	db #24,#30,#24,#30,#24,#30,#29,#18
	db #29,#18,#29,#0c,#29,#24,#22,#0c
	db #22,#0c,#22,#0c,#22,#0c,#22,#0c
	db #22,#0c,#22,#0c,#22,#0c,#ff,#47
	db #01,#29,#60,#28,#60,#2b,#60,#26
	db #30,#2b,#30,#45,#01,#28,#24,#28
	db #24,#26,#18,#28,#60,#28,#24,#28
	db #24,#26,#18,#28,#60,#ff,#09,#18
	db #15,#18,#09,#18,#15,#18,#09,#18
	db #15,#18,#09,#18,#08,#18,#07,#18
	db #13,#18,#07,#18,#13,#18,#07,#18
	db #13,#18,#07,#18,#08,#18,#09,#18
	db #15,#18,#09,#18,#15,#18,#09,#18
	db #15,#18,#09,#18,#07,#18,#02,#18
	db #0e,#18,#02,#18,#0e,#18,#07,#18
	db #13,#18,#ff,#05,#18,#11,#18,#05
.l7601 equ $ + 7
	db #18,#11,#18,#05,#18,#11,#18,#05
	db #18,#11,#18,#08,#18,#14,#18,#08
	db #18,#14,#18,#03,#18,#0f,#18,#03
	db #18,#0f,#18,#05,#18,#11,#18,#05
	db #18,#11,#18,#05,#18,#11,#18,#05
	db #18,#11,#18,#0a,#18,#16,#18,#0a
	db #18,#16,#18,#03,#18,#0f,#18,#03
	db #18,#0f,#18,#ff,#02,#18,#0e,#18
	db #02,#18,#0e,#18,#09,#18,#15,#18
	db #09,#18,#15,#18,#0c,#18,#18,#18
	db #0c,#18,#18,#18,#07,#18,#13,#18
	db #07,#18,#13,#18,#09,#18,#15,#18
	db #09,#18,#07,#18,#09,#18,#15,#18
	db #09,#18,#15,#18,#09,#18,#15,#18
	db #09,#18,#07,#18,#09,#18,#15,#18
	db #09,#18,#15,#18,#ff,#00,#00
;
.init_music	; added by Megachur
;
	call real_init_music
	ld hl,evt_bloc
	ld bc,#8100
	ld de,play_music
	jp #bcd7	; call play_music every CRT interrupt
evt_bloc
	db #00,#00,#00,#00,#00,#00
	db #00,#00,#00
;
.game_name
	db "BD Story 1",0
.game_year
	db "1991",0
.game_publisher
	db "JLM & MLD",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
